<template>
    <div class="search-bar">
        <el-form :inline="true">

            <el-form-item label="名称">
                <el-input v-model="filter.name" placeholder="名称" />
            </el-form-item>
            <el-form-item label="价格">
                <el-input v-model="filter.price" placeholder="价格" />
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="do_search">搜索</el-button>
            </el-form-item>
        </el-form>
    </div>

    <el-table :data="commentList">

        <el-table-column prop="name" label="商品名称">
            <template #default="scope">

                <img :src="scope.row.goods_image" alt="">
                <span>{{ scope.row.goods_name }}</span>
            </template>
        </el-table-column>
        <el-table-column prop="author" label="作者"></el-table-column>
        <el-table-column prop="score" label="评分"></el-table-column>
        <el-table-column prop="status" label="状态">
            <template #default="scope">
                <span v-if="scope.row.status==0">隐藏</span>
                <span v-if="scope.row.status==1">显示</span>
            </template>
        </el-table-column>
        <el-table-column prop="date" label="日期"></el-table-column>
        <el-table-column prop="" label="操作">
            <template #default="scope">
                <el-button type="primary" @click="delete(scope.row)">删除</el-button>
                <a class="el-button el-button--primary "
                   :href="'/main/comment/edit/' + scope.row.id">
                    编辑
                </a>
            </template>

        </el-table-column>
</el-table>
</template>

<script lang="ts" setup >

import { ref } from "vue";
import axios from "axios";
// import {ElMessage} from "element-plus";


const total = ref<number>(10)
const per_page = ref<number>(15)
const current_page = ref<number>(1)

const commentList = ref<object>();
const filter:any = ref<object>({

    name: '',
    status: '',
    price: '',
    category_name: '',
    brand_name: '',
});

const get_comment_list = () => {
    var url = window.VITE_URL + '/admin.goodsComment/get_list';

    if (filter.value.name) {
        url += '&name=' + filter.value.name;
    }
    if (filter.value.status != '') {
        url += '&status=' + filter.value.status;
    }
    if (filter.value.price) {
        url += '&price=' + filter.value.price;
    }
    if (filter.value.category_name) {
        url += '&category_name=' + filter.value.category_name;
    }

    if (filter.value.brand_name) {
        url += '&brand_name=' + filter.value.brand_name;
    }

    axios.get(url).then(function (res) {

        commentList.value = res.data;

    });
}

get_comment_list();

const do_search = () => {

}
</script>